//
//  SMRecordView.m
//  lishiminOC
//
//  Created by p2p on 16/10/17.
//  Copyright © 2016年 p2p. All rights reserved.
//

#import "SMRecordView.h"

@interface SMRecordView ()
@property (nonatomic,strong)UIImageView *titleImageView;
@property (nonatomic,strong)UILabel *recordLabel;
@property (nonatomic,strong)UIImageView *backImageView;
@property (nonatomic,strong)UIView *intervalView;
@property (nonatomic,strong)UIButton *clickButton;
@end
@implementation SMRecordView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //设置界面UI
        self.backgroundColor = [UIColor whiteColor];
        [self setupUI];
    }
    return  self;
}
#pragma mark - 设置UI界面
- (void)setupUI{
    UIImageView *titleImageView = [[UIImageView alloc]init];
    self.titleImageView = titleImageView;
    [self addSubview:titleImageView];
    
    UILabel *recordLabel = [[UILabel alloc]init];
    recordLabel.textColor = [UIColor redColor];
    recordLabel.textAlignment = NSTextAlignmentLeft;
    recordLabel.font = [UIFont systemFontOfSize:14];
    self.recordLabel = recordLabel;
    [self addSubview:recordLabel];
    
    UIImageView *backImageView = [[UIImageView alloc]init];
    self.backImageView = backImageView;
    [self addSubview:backImageView];
    
    UIView *intervalView = [[UIView alloc]init];
    intervalView.backgroundColor = [UIColor grayColor];
    self.intervalView = intervalView;
    [self addSubview:intervalView];
    
}
- (void)setUIDataWithDic:(NSDictionary *)dataDic andIntervalDisplay:(BOOL)isDisplay{
    self.titleImageView.image = [UIImage imageNamed:dataDic[@"imageTitleString"]];
    self.recordLabel.text = dataDic[@"titleName"];
    self.backImageView.image = [UIImage imageNamed:dataDic[@"backImageString"]];
    self.intervalView.hidden = isDisplay;
}
- (void)layoutSubviews{
    __weak __typeof(&*self)weakSelf = self;
    [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.mas_left).with.offset(15);
        make.width.mas_equalTo(@15);
        make.height.mas_equalTo(@15);
    }];
    
    [self.recordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(weakSelf.titleImageView.mas_right).with.offset(15);
        make.width.mas_equalTo(@100);
        make.height.mas_equalTo(@15);
    }];
    
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.right.equalTo(weakSelf.mas_right).with.offset(-15);
        make.width.mas_equalTo(@15);
        make.height.mas_equalTo(@15);
    }];
    
    [self.intervalView mas_makeConstraints:^(MASConstraintMaker *make) {
        //
        make.bottom.equalTo(weakSelf.mas_bottom);
        make.right.equalTo(weakSelf.mas_right);
        make.left.equalTo(weakSelf.recordLabel.mas_left);
        make.height.mas_equalTo(@1);
    }];
    
}


@end
